//
//  BloodSugarEditViewController.m
//  安好
//
//  Created by 马晓良 on 14-12-4.
//  Copyright (c) 2014年 lianchuangbrother. All rights reserved.
//

#import "BloodSugarEditViewController.h"
#import "SignsDataCell.h"
#import "MyHealthLogModel.h"
#import "ImportSignDatailViewController.h"
#import "UserId.h"
@interface BloodSugarEditViewController ()<UITableViewDataSource,UITableViewDelegate>
{
    // 控制navi右边button的状态 以及cell的点击 三个button的显隐
    BOOL editChange;
    // 控制是否执行方法 以及cell的删除
    BOOL controlMethod;
    
    //  控制button不能一直点击相刷新
    BOOL beforeBool;
    BOOL afterBool;
    NSInteger pages;
}
/**
 *  展示数据
 */
@property (strong, nonatomic) IBOutlet UITableView *bloodSugarEditTableView;
/**
 *  餐前的线条
 */
@property (strong, nonatomic) IBOutlet UIView *beforeEatingLine;
/**
 *  餐后的线条
 */
@property (strong, nonatomic) IBOutlet UIView *afterEatLine;

/**
 *  左右naviBar的button
 */
@property (nonatomic, strong) UIButton *backButton;
@property (nonatomic, strong) UIButton *editButton;
/**
 *  定义一个数来判断三个按钮的执行
 */
@property (nonatomic, assign) NSInteger buttonSequence;
/**
 *  分别显示餐前和餐后的数组
 */
@property (nonatomic, strong) NSMutableArray *beforeDataArray;
@property (nonatomic, strong) NSMutableArray *afterDataArray;
/**
 *  删除的数据的字典
 */
@property (nonatomic, strong) NSMutableDictionary *deleteDic;

@property (nonatomic, strong) NSIndexPath *selfCellIndexPath;
@end

@implementation BloodSugarEditViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    editChange = NO;
    controlMethod = NO;
    pages = 1;
    self.buttonSequence = 100;
    self.selfCellIndexPath = [[NSIndexPath alloc] init];
//    self.navigationItem.title = self.naviTitleStr;
    self.bloodSugarEditTableView.dataSource = self;
    self.bloodSugarEditTableView.delegate = self;
    self.bloodSugarEditTableView.backgroundColor = [ClassMethodsViewController colorWithHexString:BACK_BACKGROUNDCOLOR_16];
    [self _parseHeightAndWeightDataSource];
    self.navigationItem.title = @"餐前血糖记录";
    [self setNaviBarAttribute];
    beforeBool = NO;
    afterBool = YES;
     [self.bloodSugarEditTableView addFooterWithTarget:self action:@selector(_parseHeightAndWeightDataSource)];
    if (kScreenWidth == 414) {
        self.presentView.frame = CGRectMake(0, 0, kScreenWidth, 55);
        self.beforeEatingButton.frame = CGRectMake(0, 0, 206, 55);
        self.beforeEatingButton.titleLabel.font = [UIFont systemFontOfSize:BUTTON_TEXTLABEL_FOUNT_SIZE];
        self.afterEatingButton.frame = CGRectMake(207, 0, 207, 55);
        self.afterEatingButton.titleLabel.font = [UIFont systemFontOfSize:BUTTON_TEXTLABEL_FOUNT_SIZE];
        
        self.beforeEatingLine.frame = CGRectMake(0, 54, 206, 1);
        self.afterEatLine.frame = CGRectMake(207, 54, 207, 1);
        self.bloodSugarEditTableView.frame = CGRectMake(0, 55, kScreenWidth, kScreenHeight - 55 - 64);

    }
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - button的实现方法 -
- (IBAction)beforeEatingButtonAction:(UIButton *)sender {
    self.afterEatLine.hidden = YES;
    self.beforeEatingLine.hidden = NO;
    self.buttonSequence = 100;
    self.navigationItem.title = @"餐前血糖记录";
    [self.afterDataArray removeAllObjects];
    if (beforeBool) {
        pages = 1;
        [self _parseHeightAndWeightDataSource];
        beforeBool = NO;
        afterBool = YES;
    }
}


- (IBAction)afterEatingButtonAction:(UIButton *)sender {
    self.afterEatLine.hidden = NO;
    self.beforeEatingLine.hidden = YES;
    self.buttonSequence = 200;
    self.navigationItem.title = @"餐后血糖记录";
    [self.beforeDataArray removeAllObjects];
    if (afterBool) {
        pages = 1;
        [self _parseHeightAndWeightDataSource];
        beforeBool = YES;
        afterBool = NO;
    }
}

#pragma mark - 设置naviBar 并实现左右naviBar button方法 -
- (void)setNaviBarAttribute{
    /**
     *  设置左NaviBar和右naviBar
     */
    UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    
    self.editButton.titleLabel.font = [UIFont systemFontOfSize:15];
    self.backButton.titleLabel.font = [UIFont systemFontOfSize:15];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.editButton];
    
    self.afterEatLine.hidden = YES;

}

/**
 *  返回主页面
 */
- (void)handleBackButtonAction{
//    if (!editChange) {
        [self.navigationController popViewControllerAnimated:YES];
//    }else{
//        // 执行删除所有操作
//        MyNSLog("删除所有数据");
//        editChange = NO;
//        self.presentView.hidden = NO;
//        self.bloodSugarEditTableView.frame = CGRectMake(0, 44, kScreenWidth, kScreenHeight - 108);
//        [self.editButton setTitle:@"编辑" forState:UIControlStateNormal];
//        [self.bloodSugarEditTableView reloadData];
//    }
    
}

/**
 *  编辑按钮
 */
- (void)handleEditButtonAction{
    MyNSLog("%@", editChange ? @"yes":@"no");
    if (!editChange) {
        editChange = YES;
        [self.backButton setImage:[UIImage imageNamed:@"公用_返回"] forState:UIControlStateNormal];
        UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.backButton];
        self.navigationItem.leftBarButtonItem = leftBarButtonItem;
//        [self.backButton setTitle:@"删除所有" forState:UIControlStateNormal];
        [self.editButton setTitle:@"取消" forState:UIControlStateNormal];
        
        // 控制三个按钮的显隐
        self.presentView.hidden = YES;
        self.bloodSugarEditTableView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight - 64);
    }
    else{
        editChange = NO;
        [self.backButton setImage:[UIImage imageNamed:@"公用_返回"] forState:UIControlStateNormal];
//        self.backButton.frame = CGRectMake(0, 0, 23, 23);
        [self.backButton setTitle:@"" forState:UIControlStateNormal];
        
        [self.editButton setTitle:@"编辑" forState:UIControlStateNormal];
        
        self.presentView.hidden = NO;
        if (kScreenWidth == 414) {
            self.bloodSugarEditTableView.frame = CGRectMake(0, 44, kScreenWidth, kScreenHeight - 55 - 64);
        }else{
            self.bloodSugarEditTableView.frame = CGRectMake(0, 44, kScreenWidth, kScreenHeight - 108);
        }
    }
    [self.bloodSugarEditTableView reloadData];
    
    if (!controlMethod) {
        controlMethod = YES;
    }else{
        // 然后执行数据上传
        MyNSLog("上传数据");
        controlMethod = NO;
    }
    
}




#pragma mark - tableView的代理方法 -

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (self.buttonSequence == 100) {
        return self.beforeDataArray.count;
    }else if (self.buttonSequence == 200){
        return self.afterDataArray.count;
    }
    return 0;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (kScreenWidth == 414) {
        return 54;
    }else{
        return 44;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.1;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    SignsDataCell *cell = [tableView dequeueReusableCellWithIdentifier:@"signsDataCell"];
    if (!cell) {
        if (kScreenWidth == 414) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"SignsDataCell" owner:self options:nil] lastObject];
        }else{
            cell = [[[NSBundle mainBundle] loadNibNamed:@"SignsDataCell" owner:self options:nil] firstObject];
        }
    }
    [cell.editButton addTarget:self action:@selector(cellEditButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    MyHealthLogModel *healthModel = [[MyHealthLogModel alloc] init];
    if (self.buttonSequence == 100) {
        healthModel = self.beforeDataArray[indexPath.row];
        cell.contentLabel.text = [NSString stringWithFormat:@"%@mmol/L",healthModel.ppbg];
        cell.timeLabel.text = [NSString stringWithFormat:@"%@",[self getDate:healthModel.dateline]];
    }else if (self.buttonSequence == 200){
        healthModel = self.afterDataArray[indexPath.row];
        cell.contentLabel.text = [NSString stringWithFormat:@"%@mmol/L",healthModel.ppbs];
        cell.timeLabel.text = [self getDate:healthModel.dateline];
    }
    
    if (editChange) {
        //最终的位置
        [cell.editButton setBackgroundImage:[UIImage imageNamed:@"日志_删除"] forState:UIControlStateNormal];
        if (kScreenWidth == 414) {
            cell.timeLabel.frame = CGRectMake(kScreenWidth - 168, 20, 150, 15);
            cell.jumpImageView.frame = CGRectMake(kScreenWidth, 18, 18, 18);
        }else{
            cell.timeLabel.frame = CGRectMake(kScreenWidth - 165, 14, 150, 15);
            cell.jumpImageView.frame = CGRectMake(kScreenWidth, 15, 15, 15);
        }
    }else{
        [cell.editButton setBackgroundImage:[UIImage imageNamed:@"日志_内容"] forState:UIControlStateNormal];
        if (kScreenWidth == 414) {
            cell.timeLabel.frame = CGRectMake(kScreenWidth - 183, 20, 150, 15);
            cell.jumpImageView.frame = CGRectMake(kScreenWidth - 33 , 18, 18, 18);
        }else{
            cell.timeLabel.frame = CGRectMake(kScreenWidth - 180, 14, 150, 15);
            cell.jumpImageView.frame = CGRectMake(kScreenWidth - 30 , 15, 15, 15);
        }
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (!editChange) {
        ImportSignDatailViewController *importSignVC = [[ImportSignDatailViewController alloc] init];
        if (self.buttonSequence == 100) {
            importSignVC.detailsTypeStr = [NSString stringWithFormat:@"血糖"];
            importSignVC.bloodInteger = 100;
            importSignVC.healthModel = self.beforeDataArray[indexPath.row];
            [self.navigationController pushViewController:importSignVC animated:YES];
        }else if (self.buttonSequence == 200){
            importSignVC.detailsTypeStr = [NSString stringWithFormat:@"血糖"];
            importSignVC.bloodInteger = 200;
            importSignVC.healthModel = self.afterDataArray[indexPath.row];
            [self.navigationController pushViewController:importSignVC animated:YES];
        }
        
        MyNSLog("我触发了方法 %d", indexPath.row);
    }else{
        MyNSLog("我是不会触发方法的");
    }
}

//设置tableView每一行的编辑样式
-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
    return UITableViewCellEditingStyleDelete;
}


//设置删除时显示的文字
-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
    return @"删除";
}

-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
    if (!editChange) {
        return YES;
    }else return NO;
    
}

-(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath{
    return YES;
}


//触发删除按钮的方法
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
    self.selfCellIndexPath = indexPath;
    if (self.buttonSequence == 100) {
         MyHealthLogModel *CurrentCellModel = [self.beforeDataArray objectAtIndex:indexPath.row];
        [self.deleteDic setValue:CurrentCellModel.logid forKey:@"logid"];
        [self.deleteDic setValue:CurrentCellModel.dateline forKey:@"dateline"];
        [self deleteDataSource];
    }else if (self.buttonSequence == 200){
         MyHealthLogModel *CurrentCellModel = [self.afterDataArray objectAtIndex:indexPath.row];
        [self.deleteDic setValue:CurrentCellModel.logid forKey:@"logid"];
        [self.deleteDic setValue:CurrentCellModel.dateline forKey:@"dateline"];
        [self deleteDataSource];
    }
}



#pragma mark - cell中button的执行方法 -
- (void)cellEditButtonAction:(UIButton *)sender{
    SignsDataCell *cell = nil;
    UIView  *view = sender.superview;
    for (NSInteger i = 0; i < 1; ) {
        if ([view isKindOfClass:[SignsDataCell class]]) {
            cell = (SignsDataCell *)view;
            break;
        }else{
            view =view.superview;
        }
    }
    self.selfCellIndexPath = [self.bloodSugarEditTableView indexPathForCell:cell];
    
    if (controlMethod) {
        MyHealthLogModel *CurrentCellModel = [[MyHealthLogModel alloc] init];
        if (self.buttonSequence == 100) {
            CurrentCellModel = [self.beforeDataArray objectAtIndex:self.selfCellIndexPath.row];
            [self.deleteDic setValue:CurrentCellModel.logid forKey:@"logid"];
            [self.deleteDic setValue:CurrentCellModel.dateline forKey:@"dateline"];
            [self deleteDataSource];
        }else if (self.buttonSequence == 200){
            CurrentCellModel = [self.afterDataArray objectAtIndex:self.selfCellIndexPath.row];
            [self.deleteDic setValue:CurrentCellModel.logid forKey:@"logid"];
            [self.deleteDic setValue:CurrentCellModel.dateline forKey:@"dateline"];
            [self deleteDataSource];
        }
    }
}


#pragma mark - 网路数据请求 -
- (void)_parseHeightAndWeightDataSource{
    [self showActionView];
    // 获取url地址
    NSString * postURL = [NSString stringWithFormat:@"%@user/log/",kBaseURL];
    MyNSLog("%@",[UserId shareUid].uidStr);
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    
    [parameters setValue:kPlatform forKey:@"platform"];
    [parameters setValue:kVersion forKey:@"version"];
    [parameters setValue:[NSString stringWithFormat:@"%ld",(long)pages] forKey:@"page"];
    if (self.buttonSequence == 100) {
        [parameters setValue:@"9" forKey:@"type"];
    }else if (self.buttonSequence == 200){
        [parameters setValue:@"15" forKey:@"type"];
    }
    [parameters setValue:[UserId shareUid].uidStr forKey:@"uid"];
    
    MyNSLog("字典 == %@", parameters);
    [manager POST:postURL parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSNumber * statusNum = [responseObject objectForKey:@"status"];
        NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
        NSString * statusString = [numberFormatter stringFromNumber:statusNum];
        MyNSLog("数组 = %@", [responseObject objectForKey:@"msg"]);

        [self hiddenActionView];
        if ([statusString isEqualToString:@"0"]) {
//            alertContent([responseObject objectForKey:@"msg"]);
            if (self.buttonSequence == 100) {
                if (self.beforeDataArray.count > 0) {
                    [self.bloodSugarEditTableView footerEndRefreshing];
                }else {
                    [self showCustomHudSingleLine:@"暂无数据"];
                }
            }else{
                if (self.afterDataArray.count > 0) {
                    [self.bloodSugarEditTableView footerEndRefreshing];
                }else{
                    [self showCustomHudSingleLine:@"暂无数据"];
                }
            }
            [self.bloodSugarEditTableView reloadData];
        }else{
            NSMutableArray *array = [[responseObject objectForKey:@"data"] isEqual:[NSNull null]]?nil:[responseObject objectForKey:@"data"];
            MyNSLog("数组 = %@", array);
            if (array != nil) {
                pages++;
                for (NSInteger i = 0; i < array.count; i++) {
                    MyHealthLogModel *healthModel = [[MyHealthLogModel alloc] init];
                    [healthModel setValuesForKeysWithDictionary:[array objectAtIndex:i]];
                    if (self.buttonSequence == 100) {
                        NSString *str = [NSString stringWithFormat:@"%@",healthModel.ppbg];
                        if (![str isEqualToString:@"0"]) {
                            if (str.length > 7) {
                                healthModel.ppbg = [NSString stringWithFormat:@"%.2f",[healthModel.ppbg floatValue]];
                            }
                            [self.beforeDataArray addObject:healthModel];
                        }
                    }
                    if (self.buttonSequence == 200){
                        NSString *str = [NSString stringWithFormat:@"%@",healthModel.ppbs];
                        MyNSLog("ppbs = %@", str);
                        if (![str isEqualToString:@"0"]) {
                            if (str.length > 7) {
                                healthModel.ppbs = [NSString stringWithFormat:@"%.2f",[healthModel.ppbs floatValue]];
                            }
                            [self.afterDataArray addObject:healthModel];
                        }
                    }
                }
                [self.bloodSugarEditTableView reloadData];
            }else if ([array count] < 20){
                [self.bloodSugarEditTableView footerEndRefreshing];
            }
            MyNSLog("获取到的字典=====%@", self.afterDataArray);
             [self.bloodSugarEditTableView reloadData];
        }
        [self.bloodSugarEditTableView footerEndRefreshing];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//        MyNSLog("%@", error);
        [self hiddenActionView];
        [self.bloodSugarEditTableView footerEndRefreshing];
    }];
}


#pragma mark - 删除数据 -
- (void)deleteDataSource{
    NSString * postURL = [NSString stringWithFormat:@"%@user/logdel/",kBaseURL];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [self.deleteDic setValue:kPlatform forKey:@"platform"];
    [self.deleteDic setValue:kVersion forKey:@"version"];
    if (self.buttonSequence == 100) {
        [self.deleteDic setValue:@"9" forKey:@"type"];
    }else if (self.buttonSequence == 200){
        [self.deleteDic setValue:@"15" forKey:@"type"];
    }
    //    MyNSLog("删除的字典 = %@", self.deleteDic);
    [manager POST:postURL parameters:self.deleteDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSNumber * statusNum = [responseObject objectForKey:@"status"];
        NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
        NSString * statusString = [numberFormatter stringFromNumber:statusNum];
        if ([statusString isEqualToString:@"0"]) {
            [self showCustomHudSingleLine:@"删除失败"];
        }else{
            if (self.buttonSequence == 100) {
               [self.beforeDataArray removeObjectAtIndex:self.selfCellIndexPath.row];
            }else if (self.buttonSequence == 200){
                [self.afterDataArray removeObjectAtIndex:self.selfCellIndexPath.row];
            }
            MyNSLog("========%@========", [responseObject objectForKey:@"msg"]);
        }
        [self.bloodSugarEditTableView reloadData];
    } failure:nil];
    
}


#pragma mark - 获取的时间戳转换为时间 -
- (NSString *)getDate:(NSString *)string{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    dateFormatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Shanghai"];
    [dateFormatter setDateFormat:@"yyyy年MM月dd日 HH:mm"];
    NSDate *theday = [NSDate dateWithTimeIntervalSince1970:[string doubleValue]];
    return [dateFormatter stringFromDate:theday];
}


#pragma mark - 懒加载 -

- (NSMutableArray *)beforeDataArray{
    if (_beforeDataArray == nil) {
        self.beforeDataArray = [NSMutableArray array];
    }
    return _beforeDataArray;
}

- (NSMutableArray *)afterDataArray{
    if (_afterDataArray == nil) {
        self.afterDataArray = [NSMutableArray array];
    }
    return _afterDataArray;
}


- (NSMutableDictionary *)deleteDic{
    if (_deleteDic == nil) {
        self.deleteDic = [NSMutableDictionary dictionary];
    }
    return _deleteDic;
}

/**
 *  返回按钮
 *
 *  @return backButton
 */
- (UIButton *)backButton{
    if (_backButton == nil) {
        self.backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        self.backButton.frame = CGRectMake(0, 0, 23, 23);
        [self.backButton setImage:[UIImage imageNamed:@"公用_返回"] forState:UIControlStateNormal];
        self.backButton.titleLabel.font = [UIFont systemFontOfSize:13];
        self.backButton.titleLabel.textAlignment = NSTextAlignmentLeft;
        [self.backButton addTarget:self action:@selector(handleBackButtonAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _backButton;
}

/**
 *  编辑按钮
 *
 *  @return editButton
 */
- (UIButton *)editButton{
    if (_editButton == nil) {
        self.editButton = [UIButton buttonWithType:UIButtonTypeCustom];
        self.editButton.frame = CGRectMake(0, 0, 30, 23);
        [self.editButton setTitle:@"编辑" forState:UIControlStateNormal];
        self.editButton.titleLabel.font = [UIFont systemFontOfSize:13];
        [self.editButton addTarget:self action:@selector(handleEditButtonAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _editButton;
}

//- (NSMutableArray *)getBefore{
//    NSMutableArray *array = [NSMutableArray array];
//    MyHealthLogModel *healthModel = [[MyHealthLogModel alloc] init];
//    for (int i = 0; i < self.beforeDataArray.count; i++) {
//        healthModel = self.beforeDataArray[i];
//        NSString *str = [NSString stringWithFormat:@"%@",healthModel.ppbg];
//        if (![str isEqualToString:@"0"]) {
//            [array addObject:healthModel.ppbg];
//        }
//    }
//    return array;
//}
//
//- (NSMutableArray *)getBeforeDate{
//    NSMutableArray *array = [NSMutableArray array];
//    MyHealthLogModel *healthModel = [[MyHealthLogModel alloc] init];
//    for (int i = 0; i < self.beforeDataArray.count; i++) {
//        healthModel = self.beforeDataArray[i];
//         NSString *str = [NSString stringWithFormat:@"%@",healthModel.ppbg];
//        if (![str isEqualToString:@"0"]) {
//            [array addObject:healthModel.dateline];
//        }
//    }
//    return array;
//}
//
//
//- (NSMutableArray *)getafter{
//    NSMutableArray *array = [NSMutableArray array];
//    MyHealthLogModel *healthModel = [[MyHealthLogModel alloc] init];
//    for (int i = 0; i < self.afterDataArray.count; i++) {
//        healthModel = self.afterDataArray[i];
//         NSString *str = [NSString stringWithFormat:@"%@",healthModel.ppbs];
//        if (![str isEqualToString:@"0"]) {
//            [array addObject:healthModel.ppbs];
//        }
//    }
//    return array;
//}
//
//- (NSMutableArray *)getafterDate{
//    NSMutableArray *array = [NSMutableArray array];
//    MyHealthLogModel *healthModel = [[MyHealthLogModel alloc] init];
//    for (int i = 0; i < self.afterDataArray.count; i++) {
//        healthModel = self.afterDataArray[i];
//        NSString *str = [NSString stringWithFormat:@"%@",healthModel.ppbs];
//        if (![str isEqualToString:@"0"]) {
//            [array addObject:healthModel.dateline];
//        }
//    }
//    return array;
//}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
